﻿<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <CustomAction Id="SPDatasheetButtonButton"
                RegistrationType="ContentType"
                RegistrationId="0x01"
                Location="CommandUI.Ribbon.ListView"
                Rights="EditListItems">
    <CommandUIExtension>
      <CommandUIDefinitions>
        <CommandUIDefinition Location="Ribbon.List.ViewFormat.Controls._children">
          <Button Id="SPDatasheetButton.OpenInDatasheetView"
                Alt="$Resources:core,cui_ButDataSheetView;"
                Image16by16="/_layouts/$Resources:core,Language;/images/formatmap16x16.png" Image16by16Top="-48" Image16by16Left="-144"
                Image32by32="/_layouts/$Resources:core,Language;/images/formatmap32x32.png" Image32by32Top="0" Image32by32Left="-288"
                LabelText="$Resources:core,cui_ButDataSheetView;"
                ToolTipTitle="$Resources:core,cui_ButDataSheetView;"
                ToolTipDescription="$Resources:core,cui_STT_ButDatasheetView;"
                Sequence="10"
                Command="SPDatasheet_OpenInDatasheetView"
                TemplateAlias="o1"
                />
        </CommandUIDefinition>
        <CommandUIDefinition Location="Ribbon.Library.ViewFormat.Controls._children">
          <Button Id="SPDatasheetButton.OpenInDatasheetView"
                Alt="$Resources:core,cui_ButDataSheetView;"
                Image16by16="/_layouts/$Resources:core,Language;/images/formatmap16x16.png" Image16by16Top="-48" Image16by16Left="-144"
                Image32by32="/_layouts/$Resources:core,Language;/images/formatmap32x32.png" Image32by32Top="0" Image32by32Left="-288"
                LabelText="$Resources:core,cui_ButDataSheetView;"
                ToolTipTitle="$Resources:core,cui_ButDataSheetView;"
                ToolTipDescription="$Resources:core,cui_STT_ButDatasheetView;"
                Sequence="10"
                Command="SPDatasheet_OpenInDatasheetView"
                TemplateAlias="o1"
                />
        </CommandUIDefinition>
      </CommandUIDefinitions>
      <CommandUIHandlers>
        <CommandUIHandler Command="SPDatasheet_OpenInDatasheetView" CommandAction="javascript: if (ctx.rootFolder == '') { var RootFolder = ctx.listUrlDir; } else { var RootFolder = ctx.rootFolder; } var url='{SiteUrl}/_layouts/15/SPDatasheet/Datasheet.aspx?RootFolder='+ RootFolder +'&amp;View='+ctx.view; window.location.href=url;" EnabledScript="return typeof(window.ActiveXObject) == 'function'; " />
      </CommandUIHandlers>
    </CommandUIExtension>
  </CustomAction>
</Elements>
